        <div class="container" id="main">
            <div class="row" id="survey-info">
                <?php //echo $this->renderPartial('/layouts/left',array("active"=>"survey"))?>
                <div class="col-md-10 right">
                    <form role="form" class="form-horizontal">
                        <div class="well well-sm" style="margin-top:10px;"><strong>第1步填写基本信息</strong></div>
                        <div class="form-group">
                            <label for="survey-question-title" class="col-sm-2 control-label"><span class="CH">*</span>调查标题</label>

                            <div class="col-sm-5">
                                <input type="text" id="survey-title"  class="form-control" placeholder="调查标题" value="<?php echo $title;?>">
                                <textarea id="survey-description" row="3" style="margin-top:10px;display:none;" class="form-control"><?php echo $desc;?></textarea>
                            </div>
                            <p class="help-inline"><a class="btn btn-link btn-survey-description-toggle"><span class="glyphicon glyphicon-edit"></span>添加描述</a></p>
                                
                        </div>
                        <div class="form-group" style="display:none;">
                            <label class="control-label col-sm-2"><span class="CH">*</span>问卷类型</label>
                            <div class="col-sm-10">
                                <label class="radio-inline">
                                    <input type="radio" name="survey-type" value="1" <?php if($type=="1"){echo "checked";}?> >文字投票
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="survey-type" value="2" <?php if($type=="2"){echo "checked";}?> >问卷调查
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="survey-type" value="3" <?php if($type=="3"){echo "checked";}?> >图片调查
                                </label>
                            </div>
                        </div>
                        <div class="well well-sm"><strong>第2步添加调查题</strong></div>
                        <fieldset id="survey-questions-list">

                            <?php
                            if(is_array($questions)){
                                $i=0;
                                foreach($questions as $key => $value)
                                {  
                                    $i ++;
                                    if($pagetype=="edit"){
                                        echo '<div class="form-group survey-question" data-survey-id="'.$voteid.'" data-question-id="'.$value['subjectid'].'">';
                                    }else{
                                        echo '<div class="form-group survey-question">';
                                    }
                                    
                                    echo '<label for="survey-question-title" class="col-sm-2 control-label">调查题目'.$i.'</label>';
                                    echo    '<div class="col-sm-10">';
                                    echo        '<table width="100%" border="0" cellpadding="0" cellspacing="0" id="edit_container">';
                                    echo            '<tbody>';
                                    echo                '<tr>';
                                    echo '<td width="450" style="text-align:left">';
                                    echo    '<input type="text" class="question-name inputlong" maxlength="200" id="" value="'.$value['title'].'">';
                                    ?>
                                    <input type="hidden" value="<?php echo $value['optiontype'];?>" class="origin-type">
                                    <select class="survey-question-type">
                                        <option value="1" <?php if($value['optiontype']=="1"){echo "selected";}?>>单选</option>
                                        <option value="2" <?php if($value['optiontype']=="2"){echo "selected";}?>>多选</option>
                                        <option value="3" <?php if($value['optiontype']=="3"){echo "selected";}?>>单行输入框</option>
                                        <option value="4" <?php if($value['optiontype']=="4"){echo "selected";}?>>多行输入框</option>
                                    </select>
                                    <!--
                                        <select class="options-templates-select" style="display:none;">
                                            <option value="self">自定义</option>
                                            <option value="star">评星</option>
                                            <option value="yes">Yes/No</option>
                                        </select>
                                    -->
                                    <select class="options-select-max" <?php if($value['optiontype']!="2"){ echo 'style="display:none;"';}?> >
                                        <option value="0" <?php if ($value['selectmax']=="0"){ echo "selected"; }?>>不限</option>
                                        <?php
                                        if($value['optiontype']=="2"||$value['optiontype']=="1"){
                                            $count = count($value['options']);
                                            for($c = 1;$c<$count;$c++){
                                                if (intval($value['selectmax'])==$c){ 
                                                    echo '<option value="'.$c.'" selected>最多'.$c.'个</option>'; 
                                                }else{
                                                    echo '<option value="'.$c.'" >最多'.$c.'个</option>';
                                                }
                                            }
                                        }
                                        ?>
                                    </select>

                                    <span><label><input name="question-ismust" class="question-ismust" type="checkbox" <?php if($value['answertype'] == "2"){echo "checked";} ?>>必选</label></span>
                                    <span class="btn-question-description-toggle"><b class="caret"></b><u>添加说明</u></span>
                                    <span class="options-control"<?php if($value['optiontype']!="1" && $value['optiontype']!="2"){ echo 'style="display:none;"'; } ?>>
                                        <span class="btn-add-option">增加选项</span>
                                        <span class="btn-add-other-option">其他选项</span>
                                    </span>
                                    <div>
                                        <textarea class="question-description" row="2" class="form-control"><?php echo $value['desc'];?></textarea>
                                    </div>

                                    </td>
                                    <td width="80" rowspan="2" valign="top" style="padding:20px 0">
                                        <div class="btn-group btn-group-vertical">
                                            <a class="btn btn-default btn-del-question">删除</a>
                                            <?php if($pagetype=="edit"){
                                                echo '<a class="btn btn-default btn-save-question">确认</a>';
                                                //echo '<a class="btn btn-default btn-add-option">添加选项</a>';
                                            }?>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="450" style="text-align:left">

                                        <div class="question-content">
                                            <div class="question-select" <?php  if($value['optiontype'] != "1"&&$value['optiontype'] != "2"){echo 'style="display:none;"';}?>>
                                                
                                                <table class="table table-condensed options-list">
                                                    <tbody >
                                                        <?php
                                                        $j = 0 ;
                                                        $otheranswer = array();
                                                        foreach($value['options'] as $k => $v)
                                                        {   
                                                            if($v['otheranswer']=="1"){
                                                                $otheranswer = $v;
                                                            }else{
                                                                $j++;
                                                                echo '<tr class="option" data-id="'.$v['optionid'].'">';
                                                                echo    '<td class="col-sm-1">'.$j.'</td>';
                                                                echo    '<td class="col-sm-5"><input placeholder="选项标题" class="option-title" optionid="'.$v['optionid'].'" value="'.$v['title'].'"></td>';
                                                                echo    '<td class="col-sm-2">';
                                                                echo        '<input placeholder="图片链接" type="text" class="option-img" value="'.$v['theme'].'">';
                                                                echo    '</td>';
                                                                echo    '<td class="col-sm-2">';
                                                                echo        '<span class="glyphicon glyphicon-upload btn-upload-img"></span>';
                                                                echo        '<span class="glyphicon glyphicon-remove btn-del-option" title="删除"></span>';
                                                                echo    '</td>';
                                                                echo '</tr>';
                                                            }                                                           
                                                        }
                                                        ?>
                                                    </tbody>
                                                </table>

                                                <table class="table table-condensed options-other" <?php if(!isset($otheranswer['optionid'])){echo 'style="display:none;"';}?>>
                                                    <tbody >
                                                        <?php
                                                            $v = $otheranswer;
                                                            echo '<tr class="option" data-id="'.$v['optionid'].'">';
                                                            echo    '<td class="col-sm-1">其他</td>';
                                                            echo    '<td class="col-sm-5"><input placeholder="其他" class="option-title" optionid="'.$v['optionid'].'" value="" disabled></td>';
                                                            echo    '<td class="col-sm-2">';
                                                            echo        '<input placeholder="图片链接" type="text" class="option-img" value="'.$v['theme'].'" disabled>';
                                                            echo    '</td>';
                                                            echo    '<td class="col-sm-2">';
                                                            echo        '<span class="glyphicon glyphicon-upload btn-upload-img"></span>';
                                                            //echo        '<span class="glyphicon glyphicon-remove btn-del-option" title="删除"></span>';
                                                            echo    '</td>';
                                                            echo '</tr>';
                                                        ?>
                                                    </tbody>
                                                </table>
                                            </div>

                                            <div class="question-input" <?php if($value['optiontype'] != "4" && $value['optiontype'] != "3"){ echo 'style="display:none"';}?>>
                                                <input type="hidden" class="option-input" value="<?php echo intval($value['options'][0]['optionid'])?>">
                                                用户可输入：最少<input type="text" class="inputshort length_min" maxlength="3" value="<?php echo intval($value['options'][0]['length_min'])?>">，
                                                最多<input type="text" class="inputshort length_max" maxlength="3" value="<?php echo intval($value['options'][0]['length_max'])?>">字
                                            </div>
                                        
                                            <div class="question-answer">
                                                答案：<input type="text" class="inputlong" maxlength="200" value="<?php echo $value['answer'];?>">
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <?php
                    }//foreach
                }//is array
                ?>


                    </fieldset>
                    <div class="form-group">
                        <div class="col-sm-offset-2 col-sm-10">
                            <a class="btn btn-default btn-add-question"><span class="glyphicon glyphicon-plus"></span>新加一题目</a>    
                        </div>
                    </div>
                    <div class="well well-sm"><strong>第3步其它设置</strong></div>
                        <fieldset id="poll-adavanced-option">
                            <div class="form-group">
                                <label for="" class="col-sm-2 control-label" >起止时间</label>
                                <div class="col-sm-9">
                                    <input id="survey-starttime" class="datetime" value="<?php if($starttime){ echo $starttime;}else{ echo date("Y-m-d H:i");}?>">
                                    -
                                    <input id="survey-endtime" class="datetime" value="<?php if($endtime){ echo $endtime;}else{ echo date("Y-m-d H:i",strtotime("+365 day"));}?>">
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">调查配图</label>
                                <div class="col-sm-9">
                                    <input type="text" value="<?php echo $toppic;?>" id="survey-pic" placeholder="填写配图链接">
                                    <!--<input type="file" id="survey-top-pic">-->
                                    <p class="help-block">用于问卷顶端显示</p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">明细存储</label>
                                <div class="col-sm-9">
                                    <select name="survey-detail" id="survey-detail">
                                        <option value="1" <?php if($votedetail==1){echo "selected";} ?>>保存</option>
                                        <option value="2" <?php if($votedetail==2){echo "selected";} ?>>不保存</option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">参与权限</label>
                                <div class="col-sm-9">
                                    <label class="checkbox-inline"><input name="survey-rule" type="checkbox" value="1" <?php if($ruleid&1) echo "checked";?>>QQ</label>
                                    <label class="checkbox-inline"><input name="survey-rule" type="checkbox" value="2" <?php if($ruleid&2) echo "checked";?>>微信</label>
                                    <!--<label for=""><input name="survey-rule" type="checkbox" value="4" <?php if($ruleid&4) echo "checked";?>>硬件设备</label>-->
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">调查规则</label>
                                <div class="col-sm-9">
                                    <p><span>每个账号，每</span>
                                        <!--<input type="text" name="cycletime" class="inputshort" id="cycletime" maxlength="3" value="10">-->
                                        <select name="survey-cycletime" id="survey-cycletime">
                                        <option value="604800" <?php if($cycletime==604800){echo "selected";} ?>>周</option>
                                        <option value="86400" <?php if($cycletime==86400){echo "selected";} ?>>天</option>
                                        <option value="3600" <?php if($cycletime==3600){echo "selected";} ?>>小时</option>
                                        <option value="60" <?php if($cycletime==60){echo "selected";} ?>>分</option>
                                    </select>可以投<input type="text" class="inputshort" value="<?php echo $votecount?>" id="survey-limit-count">票<p>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">票数限额</label>
                                <div class="col-sm-9">
                                    <p>每天总票上限<input type="text" class="inputshort" value="<?php echo $votetotal?>" id="survey-limit-day-total">票</p>
                                </div>
                            </div>

                            

                            <div class="form-group">
                                <label class="control-label col-sm-2">结果显示</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-showflag" value="1" <?php if($showflag==1){echo "checked";}?>>始终显示
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-showflag" value="2" <?php if($showflag==2){echo "checked";}?>>提交后显示
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-showflag" value="3" <?php if($showflag==3){echo "checked";}?>>不显示
                                    </label>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="control-label col-sm-2">所属榜单</label>
                                <div class="col-sm-9">
                                    <!--//1：总榜 3：年榜 6：月榜 9：周榜-->
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-level" value="1" <?php if($level==1) echo "checked";?>>总榜
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-level" value="3" <?php if($level==3) echo "checked";?>>年榜
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-level" value="6" <?php if($level==6) echo "checked";?>>月榜
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="survey-level" value="9" <?php if($level==9) echo "checked";?>>周榜
                                    </label>
                                </div>
                            </div>
    
                            <div class="form-group">
                                <label for="survey-question-result" class="control-label col-sm-2">所属分组</label>
                                <div class="col-sm-9">
                                    <select name="" id="survery-group-id">
                                        <option value="0" <?php if($groupid==0){echo "selected";}?>>无分组</option>
                                        <option value="10000000" <?php if($groupid==10000000){echo "selected";}?>>达人秀</option>
                                        <option value="10000001" <?php if($groupid==10000001){echo "selected";}?>>测试分组</option>
                                    </select>
                                    <!--<input placeholder="填写组名"/> -->
                                </div>
                            </div>
                        </fieldset>

                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <?php 
                                if($pagetype=="edit"){
                                    echo '<a class="btn btn-default btn-edit-survey" data-survey-id="'.$voteid.'" >保存</a>';
                                }else{
                                    echo '<a class="btn btn-default btn-save-survey">保存</a>';
                                }
                                ?>
                                
                                <!--
                                    <a href="/preview/" target="_blank" class="btn btn-default btn-preview-survey">预览</a>
                                    <a class="btn btn-default btn-submit-survey">发布</a>
                                -->
                            </div>
                        </div>
                    </form>
                </div>
        </div>

        <script type="text/html" id="survey-question-template">
            <div class="form-group survey-question">
                <label for="survey-question-title" class="col-sm-2 control-label">调查题目1</label>
                <div class="col-sm-10">
                    <table width="100%" border="0" cellpadding="0" cellspacing="0" id="edit_container">
                        <tbody>
                            <tr>
                                <td width="450" style="text-align:left">
                                    <input type="text" class="question-name inputlong" maxlength="200" id="" value="调查题">
                                    <select class="survey-question-type">
                                        <option value="1">单选</option>
                                        <option value="2">多选</option>
                                        <option value="3">单行输入</option>
                                        <option value="4">多行输入</option>
                                    </select>
                                    <input type="hidden" value="1" class="origin-type">
                                    <select class="options-select-max" style="display:none;">
                                        <option value="0">不限</option>
                                        <option value="1">最多1个</option>
                                        <option value="2">最多2个</option>
                                        <option value="3">最多3个</option>
                                    </select>
                                    <span><label><input name="question-ismust" class="question-ismust" type="checkbox" checked="">必选</label></span>
                                    <span class="btn-question-description-toggle"><b class="caret"></b><u>添加说明</u></span>
                                    <span class="options-control">
                                        <span class="btn-add-option">增加选项</span>
                                        <span class="btn-add-other-option">其他选项</span>
                                    </span>
                                    <div>
                                        <textarea class="question-description" row="2" class="form-control"></textarea>
                                    </div>

                                </td>
                                <td width="80" rowspan="2" valign="top" style="padding:20px 0">
                                    <div class="btn-group btn-group-vertical">
                                        <a class="btn btn-default btn-del-question">删除</a>
                                        <!--<a class="btn btn-default btn-preview-question">预览</a>
                                        <a class="btn btn-default btn-copy-question">复制</a>-->
                                        <?php if($pagetype=="edit"){
                                           echo '<a class="btn btn-default btn-save-question">确认</a>';
                                           //echo '<a class="btn btn-default btn-add-option">添加选项</a>';
                                        }?>
                                    </div>
                                </td>
                            </tr>
                            <tr>
                                <td width="450" style="text-align:left">
                                    <div class="question-content">
                                        <div class="question-select">
                                            <table class="table table-condensed options-list">
                                                <tbody>
                                                    <tr class="option">
                                                        <td class="col-sm-1">1</td>
                                                        <td class="col-sm-5"><input placeholder="选项标题" class="option-title" ></td>
                                                        <td class="col-sm-2"><input placeholder="图片链接" type="text" class="option-img" value=""></td>
                                                        <td class="col-sm-2">
                                                            <span class="glyphicon glyphicon-upload btn-upload-img"></span>
                                                            <span class="glyphicon glyphicon-remove btn-del-option" title="删除"></span>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                            <table class="table table-condensed options-other" style="display:none;">
                                                <tbody>

                                                    <tr class="option">
                                                        <td class="col-sm-1">其他</td>
                                                        <td class="col-sm-5"><input placeholder="选项标题" class="option-title" disabled></td>
                                                        <td class="col-sm-2"><input placeholder="图片链接" type="text" class="option-img" value="" disabled></td>
                                                        <td class="col-sm-2">
                                                            <span class="glyphicon glyphicon-upload btn-upload-img"></span>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </div>
                                        
                                        <div class="question-input" style="display:none">
                                            <input type="hidden" value="" id="">
                                            用户可输入：最少<input type="text" class="inputshort" maxlength="3" value="0">，
                                            最多<input type="text" class="inputshort" maxlength="3" value="200">字
                                        </div>
                                        
                                        <div class="question-answer">
                                            答案：<input type="text" class="inputlong" maxlength="200" id="question_a_0" value="">
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
        </script>

        

        <script type="text/html" id="survey-question-select-template">
            <div class="question-select">
                <table class="table table-condensed options-list">
                    <tbody>
                        <tr class="option" data-id="">
                            <td class="col-sm-1">1</td>
                            <td class="col-sm-5"><input placeholder="选项标题" class="option-title" value=""></td>
                            <td class="col-sm-2"><input placeholder="图片链接" type="text" class="option-img" value=""></td>
                            <td class="col-sm-2">
                                <span class="glyphicon glyphicon-upload btn-upload-img"></span>
                                <span class="glyphicon glyphicon-remove btn-del-option" title="删除"></span>
                            </td>
                        </tr>
                    </tbody>
                </table>
                <table class="table table-condensed options-other">
                    <tbody>
                        <tr class="option" data-id="">
                            <td class="col-sm-1">其他</td>
                            <td class="col-sm-5"><input placeholder="选项标题" class="option-title" value="" disabled></td>
                            <td class="col-sm-2"><input placeholder="图片链接" type="text" class="option-img" value="" disabled></td>
                            <td class="col-sm-2">
                                <span class="glyphicon glyphicon-upload btn-upload-img"></span>
                                <span class="glyphicon glyphicon-remove btn-del-option" title="删除"></span>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <div class="question-answer">
                答案：<input type="text" class="inputlong" maxlength="200" id="question_a_0" value="">
            </div>
        </script>

        <script type="text/html" id="survey-question-input-template">
             <div class="question-input">
                <input type="hidden" value="" id="">
                用户可输入：最少<input type="text" class="inputshort" maxlength="3" value="0">，
                最多<input type="text" class="inputshort" maxlength="3" value="200">字
            </div>
        </script>

        <script type="text/html" id="survey-option-template">
            <tr class="option">
                <td class="col-sm-1">2</td>
                <td class="col-sm-5"><input class="option-title" value="<%=title%>" placeholder="选项标题"></td>
                <td class="col-sm-2">
                    <input placeholder="图片链接" type="text" class="option-img" value="<%=img%>" placeholder="图片链接">
                    <!--<img data-src="holder.js/30x30/auto" class="img-thumbnail" alt="30x30">-->
                </td>
                <td class="col-sm-2">
                    <span class="glyphicon glyphicon-upload btn-upload-img"></span>
                    <span class="glyphicon glyphicon-remove btn-del-option"></span>
                </td>
            </tr>
        </script>
        <script >
        $(".datetime").datetimepicker({
            language:"zh-CN",
            todayBtn: true
        });
        </script>
        <script src="<?php echo DIR_WEB; ?>/js/coral.survey.create.js"></script>